
import React, { Component } from "react";
import store from './store/index'
import axios from "axios";

export default class Page1 extends Component {


    componentDidMount() {
        axios.get('http://121.89.205.189:3000/api/pro/list').then(res => {
            console.log(res.data.data);
            store.dispatch({
                type: 'change_pro_list',
                payload: res.data.data
            })
        })
    }

    render() {
        // console.log(store.getState().count.count);
        return <>
            <h1>Page1 --- {store.getState().count.count}</h1>
            <button onClick={() => { store.dispatch({ type: 'add' }) }}>点击加 1</button>

            <ul>
                {store.getState().pro.proList && store.getState().pro.proList.map((item) => {
                    return <li key={item.proid}>{item.proname}</li>
                })}
            </ul>

        </>
    }
}